<template>
  <div class="coupon_scan_share_Get">
    <c-title :hide="false" text="优惠券领取"></c-title>
    <div class="topBg"></div>
    <div class="contenBox">
      <img src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/coupon_scan_share_bg%402x.png" alt="" />
      <div class="pos">
        <div class="top">
          <div class="pos_img">
            <img :src="info.logo" alt="" />
          </div>
          <div class="pos_title">{{ info.name }}</div>
          <template v-if="info.coupon_method == 1">
            <div class="pos_price"><span class="dp">¥</span>{{ parseFloat(info.discount) }}</div>
            <div class="pos_tips">满{{ info.enough }}元可用</div>
          </template>
          <template v-if="info.coupon_method == 2">
            <div class="pos_price">{{ parseFloat(info.discount) }} <span class="dp">折</span></div>
            <div class="pos_tips">满{{ info.enough }}立享受</div>
          </template>
        </div>
        <div class="bottom">
          <div class="coupon_date" v-if="info.start || info.end">有效期：{{ info.start ? info.start : "不限时间" }}至{{ info.end ? info.end : "不限时间" }}</div>
          <div class="coupon_date" v-if="!info.start && !info.end">不限时间</div>
          <div class="coupon_num">券张数：{{ info.num }}张</div>
        </div>
      </div>
    </div>
    <div class="btn" @click="tapConfirm">确认领取</div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      info: {}
    };
  },
  activated() {
    console.log(this.$route.query.mark);
    this.getData();
  },
  methods: {
    getData() {
      $http.get("plugin.coupon-scan-share.frontend.controllers.receive.receive-page", { mark: this.$route.query.mark }, "正在获取").then(response => {
        if (response.result == 1) {
          this.info = response.data;
        } else {
          this.$dialog.alert({ message: response.msg }).then(() => {
            this.$router.push(this.fun.getUrl("home", {}));
          });
        }
      });
    },
    tapConfirm() {
      $http.get("plugin.coupon-scan-share.frontend.controllers.receive.receive", { mark: this.$route.query.mark }, "正在获取").then(response => {
        if (response.result == 1) {
          this.$dialog.alert({ message: response.msg }).then(() => {
            this.$router.push(this.fun.getUrl("coupon", {}));
          });
        } else {
          this.$dialog.alert({ message: response.msg }).then(() => {
            this.$router.push(this.fun.getUrl("home", {}));
          });
        }
      });
    }
  }
};
</script>
<style lang="scss" scoped>
.topBg {
  width: 23.44rem;
  height: 18.66rem;
  background: linear-gradient(1deg, #f5f5f5 0%, #fd4963 100%);
}
.contenBox {
  margin: -15.4rem 1.5rem 0 1.5rem;
  padding-top: 1.625rem;
  overflow: hidden;
  box-sizing: border-box;
  position: relative;
  .pos {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
    .top {
      flex: 1;
      width: 100%;
      display: flex;
      flex-direction: column;
      align-items: center;
    }
    .bottom {
      flex-shrink: 0;
      padding-bottom: 1.5rem;
    }
    .pos_img {
      width: 3.25rem;
      height: 3.25rem;
      background: #ffffff;
      border-radius: 50%;
      border: 0.09rem solid #ffffff;
      img {
        width: 3.16rem;
        height: 3.16rem;
        border-radius: 50%;
      }
    }
    .pos_title {
      width: 14.5rem;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
      overflow: hidden;
      margin-top: 0.91rem;
      font-size: 0.88rem;
      font-weight: bold;
    }
    .pos_price {
      width: 14.5rem;
      align-items: flex-end;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      font-size: 2.5rem;
      font-weight: bold;
      color: #f15353;
      .dp {
        font-size: 1.56rem;
        margin-bottom: 0.2rem;
      }
    }
    .pos_tips {
      font-size: 0.81rem;
      color: #f15353;
      margin-top: 0.44rem;
    }
    .coupon_date {
      width: 14.5rem;
      align-items: flex-end;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      font-size: 0.81rem;
      color: #ffffff;
      text-align: center;
    }
    .coupon_num {
      width: 14.5rem;
      align-items: flex-end;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      margin-top: 0.44rem;
      font-size: 0.81rem;
      color: #ffffff;
      text-align: center;
    }
  }
  img {
    width: 100%;
    height: 100%;
  }
}
.btn {
  text-align: center;
  margin: 2rem 2.03rem;
  border-radius: 1.38rem 1.38rem 1.38rem 1.38rem;
  background: linear-gradient(179deg, #ffc8b4 0%, #ff3653 100%);
  padding: 0.91rem 0;
  font-weight: 500;
  color: #ffffff;
}
</style>
